$(function () {
    //第一个tr
    var temp_html;
    //第二个tr
    var temp2_html;
    //后台请求数据
    $.post('/keywordSearch/getCurrTab',function(res){
        // console.log(res);
        $.each(res.data,function(i, lineInfo){
            //添加相对应的的td标签等
            temp_html+="<td class='pl_sppl'>"+lineInfo.keywordName+"</td>";
            temp2_html+="<td><input type='text' class='layui-input lspl' value='"+lineInfo.peopleNum+"'></td>";
        });

        //将新添加的td标签，添加进tr标签中
        $("#lineDrop").append(temp_html);
        $("#lineDrop2").append(temp2_html);
    })
    let data1 = new Array();
    let data2 = new Array();
    $.ajax({
        type:"post",
        url:'/keywordSearch/getCurrTab',
        data: {},
        dataType:'json',
        success:function (res) {
            let data;
            if (res.state == 200){
                data = res.data;
                console.log(data);
                for (let i=0;i<data.length;i++){
                    data1[i] = data[i].keywordName;
                    data2[i] = data[i].peopleNum;
                }
                census(data1,data2);
            }
        },
        error:function(e){
            console.log("异常");

        }

    })
})

function census(data1,data2) {

    var chartDom = document.getElementById('tabcc');
    var myChart = echarts.init(chartDom);
    var option;
    option = {
        tooltip: {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow'
            }
        },
        grid: {
            left: '3%',
            right: '4%',
            bottom: '3%',
            containLabel: true
        },
        xAxis: [
            {
                type: 'category',
                data: data1,
                axisTick: {
                    alignWithLabel: true
                }
            }
        ],
        yAxis: [
            {
                type: 'value'
            }
        ],
        series: [
            {
                name: 'Direct',
                type: 'bar',
                barWidth: '60%',
                data: data2
            }
        ]
    };
    myChart.setOption(option);
}


